/* eslint valid-jsdoc: "off" */

"use strict";
const path = require("path");
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});
  config.cluster = {
    listen: {
      port: 8001, // 修改为你需要的端口号
    },
  };
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1663488893361_2216";

  // 白名单 列表
  config.routerAuth = ["/login"];
  // 自定义中间件
  config.middleware = ["auth"];

  // 数据库
  config.mysql = {
    // 单数据库信息配置
    client: {
      // host
      host: "localhost",
      // 端口号
      port: "3306",
      // 用户名
      user: "root",
      // 密码
      password: "root",
      // 数据库名
      database: "app-admin",
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  // 跨域
  config.cors = {
    origin: "*",
    allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH",
  };

  // 文件处理
  config.multipart = {
    mode: "file",
    fileExtensions: [".mp4"],
  };

  // 生成token
  config.jwt = {
    secret: "wksdnwld", //秘钥
  };

  // 安全策略
  config.security = {
    csrf: {
      enable: false,
    },
  };

  // oss 配置
  exports.oss = {
    client: {
      accessKeyId: "LTAI5tAd5SeVvy9vm3LVNS6Y",
      accessKeySecret: "FxVrUL7CTYXRTFje7M8hcKz8LLxaic",
      bucket: "ceshi-yjy",
      region: "oss-cn-hangzhou",
      timeout: "60s",
    },
  };

  exports.static = {
    dir: [
      path.join(appInfo.baseDir, "app/public"),
      path.join(appInfo.baseDir, "uploadFiles"),
    ],
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
